package com.example.canvastest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RelativeLayout;

public class SignalViewTest extends AppCompatActivity {
    private SignalLightView signalView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        signalView=new SignalLightView(this);
        setContentView(R.layout.signal_view_test);
        RelativeLayout layout=(RelativeLayout) findViewById(R.id.heheda);
        //layout.addView(new DrawGeometryView(this));
        layout.addView(signalView);
        new Thread(new SignalLightThread()).start();
    }

    class SignalLightThread implements Runnable{

        @Override
        public void run() {
            while(!Thread.currentThread().isInterrupted()){
                try {
                    Thread.sleep(150);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                signalView.postInvalidate();//使得原来的View重绘即重新调用onDraw方法
            }
        }
    }
}
